/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package model.agent

import model.agent.question.QuestionSet;



/**
 *
 * @author itsaquestion
 */

public class AgentVariable implements AgentVariableInterface{

	String name = ""

	float value = 0

	float maxValue = 3

	int timestamp = 0 //时间戳，用于记录变量改变的ticks

	QuestionSet existentialQuestions
	QuestionSet levelQuestions

	public AgentVariable(String name , float maxValue = 3){
		this.name = name
		this.maxValue = maxValue
	}

	private void fixValue(){

		//println n
		if (value > maxValue) value = maxValue
		if (value < 0) value = 0

	}

	public void setValue(int value){

		this.value = value
		fixValue()
	}

	public int getValue(){
		return this.value
	}

	String toString(){
		return "${name}=${value}"
	}

	@Override
	public void reset() {
		this.value = 0
		this.timestamp = 0
		if(existentialQuestions!=null) existentialQuestions.lastResult = -1
		if(levelQuestions!=null) levelQuestions.lastResult!= -1
	}



}